package com.zxj.schoolxianyu.service;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zxj.schoolxianyu.dao.goodsDao;
import com.zxj.schoolxianyu.entity.goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class getTypeGoodsService {
    @Autowired(required = false)
    private goodsDao goodsDao;

    public String getTypeGoods(int classificationid) {
        EntityWrapper<goods> wrapper = new EntityWrapper<>();
        wrapper.orderBy("updatetime");
        if (classificationid == 0) {
            List<goods> gs = goodsDao.selectList(wrapper);
            return JSON.toJSONString(gs);
        }
        wrapper.eq("classificationid", classificationid);
        List<goods> gs = goodsDao.selectList(wrapper);
        if (gs.isEmpty()) return "No more data";
        else return JSON.toJSONString(gs);
    }
}
